package com.gimi.test_jpa.com.gimi.controller.wqy;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.gimi.test_jpa.com.gimi.dto.DTOInterestRate;
import com.gimi.test_jpa.com.gimi.entity.wqy.CpTestEntity;
import com.gimi.test_jpa.com.gimi.service.wqy.CptestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Api("递归测试")
@RequestMapping("/cptest")
@CrossOrigin
public class CpTestController {
    @Autowired
    private CptestService cptestService;

    @PostMapping("/getTree")
    @ApiOperation("获得子节点测试")
    public List getTree() {
        return cptestService.getTree();
    }

    @PostMapping("/test")
    @ApiOperation("测试")
    public String test(@RequestBody  DTOInterestRate dtoInterestRate) {
        Map<String, Object> map = BeanUtil.beanToMap(dtoInterestRate, false, true);
        return JSONUtil.toJsonStr(map);
    }

    @PostMapping("/getAll")
    @ApiOperation("测试")
    public List<CpTestEntity> getAll() {
        return cptestService.getAll();
    }
}
